﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TpLogic.Hamurabi
{
    public class AspNetConsole:IConsole
    {
        private System.Web.UI.WebControls.TextBox InputBox;
        private System.Web.UI.WebControls.Label ConsoleLabel;

        public AspNetConsole(System.Web.UI.WebControls.TextBox InputBox, System.Web.UI.WebControls.Label ConsoleLabel)
        {
            // TODO: Complete member initialization
            this.InputBox = InputBox;
            this.ConsoleLabel = ConsoleLabel;
        }


        public void Write(string message)
        {
            ConsoleLabel.Text += message;
        }

        public string ReadLine()
        {
            string value = InputBox.Text;
            InputBox.Text = "";
            return value;
        }

        public ConsoleKeyInfo ReadKey()
        {
            string value = InputBox.Text;
            InputBox.Text = "";
            ConsoleKeyInfo key;
            if (value.Length >= 1)
            {
                char first = value.Substring(0, 1).ToCharArray()[0];
                key = new ConsoleKeyInfo(first, ConsoleKey.NoName, false, false, false);
            }
            else 
            {
                key = new ConsoleKeyInfo();
            }
            return  key;
        }

        public void WriteLine()
        {
            ConsoleLabel.Text += "<br/>";
        }

        public void WriteLine(string message)
        {
            ConsoleLabel.Text += "<br/>" + string.Format(message);
        }

        public void WriteLine(string message, int arg1)
        {
            ConsoleLabel.Text += "<br/>" + string.Format(message, arg1);
        }

        public void WriteLine(string message, int arg1, int arg2, int arg3)
        {
            ConsoleLabel.Text += "<br/>" + string.Format(message, arg1, arg2, arg3);
        }

        public void WriteLine(string message, int arg1, int arg2, int arg3, int arg4, int arg5)
        {
            ConsoleLabel.Text += "<br/>" + string.Format(message, arg1, arg2, arg3, arg4, arg5);
        }
    }
}
